package org.geekbang.thinking.in.spring.generic;

import org.springframework.core.ResolvableType;

/**
 *  {@link ResolvableType} Demo
 *
 * @author wangyh2
 * @version v1.0
 * @since 2021-12-01 16:23
 */
public class ResolvableTypeDemo {
    public static void main(String[] args) {

        // 工厂创建
        // StringList <- ArrayList <- AbstractList <- List <- Collection
        ResolvableType resolvableType = ResolvableType.forClass(StringList.class);
        System.out.println(resolvableType.getSuperType());
        System.out.println(resolvableType.getSuperType().getSuperType());

        Class<?> resolve = resolvableType.asCollection().resolve(); // 获取 Raw Type
        System.out.println(resolve);
        ResolvableType generic = resolvableType.asCollection().getGeneric(0); // 获取泛型参数类型
        System.out.println(generic);
    }
}
